<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>提现页面</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../css/iconfont.css"/>
    <style>
        .myui-jifen-2 {
            padding-top: 2rem;
        }
    </style>
</head>
<body>
<div class="myui-jifen-box">
    <div class="myui-jifen-1">
        <h1 id="moneys">500</h1>当前余额
    </div>
    <br>
    <div class="myui-jifen-bt">
        <div class="my-jien-btn aui-btn aui-btn-info aui-btn-block aui-btn-sm" tapmode onclick="openWin('share_win')">
            推广赚钱
        </div>
    </div>
    <div id="bili2" class="myui-jifen-2">满xx元，就可以提现哦</div>
    <br>
    <div class="aui-bar aui-bar-btn" style="width:60%; " type="count" id="demo">
        <div class="aui-bar-btn-item aui-font-size-20">
            <i class="aui-iconfont aui-icon-minus"></i>
        </div>
        <div class="aui-bar-btn-item">
            <input type="number" class="aui-input aui-text-center" id="count" value="1">
        </div>
        <div class="aui-bar-btn-item aui-font-size-20">
            <i class="aui-iconfont aui-icon-plus"></i>
        </div>
    </div>
    <br>
    <div class="myui-jifen-bt">
        <div class="my-jien-btn aui-btn aui-btn-info aui-btn-block aui-btn-sm" tapmode onclick="exchange2()">确认提现
        </div>
    </div>
</div>


</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/auitab.js"></script>
<script type="text/javascript">
    var api_url = localStorage.getItem('api_url');

    apiready = function () {
        api.parseTapmode();
        api.showProgress({
            title: '正在刷新',
            text: '请稍等...',
            modal: false
        });


        api.ajax({
            url: api_url + '/login/login/share2.html',
            method: 'get',
            data: {
                values: {
                    uid: localStorage.getItem('user_id'),
                    mike_key: localStorage.getItem('mike_key')
                }
            }
        }, function (ret, err) {
            if (ret) {
                tixian_u = ret.msg.tixian;

                var moneys = $api.byId('moneys');
                moneys.innerHTML = ret.msg.moneys + '元';

                var bili2 = $api.byId('bili2');
                bili2.innerHTML = '满'+ret.msg.tixian+ '元，就可以提现哦';
                api.hideProgress();

            } else {
                alert('获取链接失败');

            }
        });
    }

    function exchange2() {
        var share = $api.val($api.byId('count'));

        if(parseInt(share)<parseInt(tixian_u)){
            api.toast({
                msg: '最低提现额是：'+tixian_u+'元~',
                duration: 5000
            });
            return;
        }

        api.ajax({
            url: api_url + '/login/login/pttixian.html',
            method: 'get',
            data: {
                values: {
                    uid: localStorage.getItem('user_id'),
                    share: share,
                    key: localStorage.getItem('mike_key')
                }
            }
        }, function (ret, err) {
            if (ret) {
                if (ret.code == 0) {
                    api.alert({
                        msg: ret.msg,
                        duration: 5000
                    });

                } else {
                    getTime();
                    var moneys = $api.byId('moneys');
                    moneys.innerHTML = ret.moneys + '元';
                    api.alert({
                        msg: '提交成功，请耐心等待，管理正在加速审核中~',
                        duration: 10000
                    });
                }

            } else {
                api.hideProgress();
                api.toast({
                    msg: '网络错误',
                    duration: 5000
                });

            }
        });
    }

    //重新获取到期时间
    function getTime() {
        api.ajax({
            url: api_url + '/login/login/veifys.html',
            method: 'get',
            data: {
                values: {
                    username: localStorage.getItem('user_name'),
                    passwd: localStorage.getItem('password'),
                    imei: api.deviceId,
                    mike_key: localStorage.getItem('mike_key')
                }
            }
        }, function (ret, err) {
            if (ret) {
                if (ret.code == 0) {
                    api.hideProgress();
                    alert('不明错误 请重新登录');
                } else if (ret.code == 1) {
                    localStorage.setItem('user_time', ret.msg['time']);
                    api.sendEvent({
                        name: 'newLoingdata',
                        extra: {}
                    });
                }
            } else {
                api.hideProgress();
                alert('网络错误！');
            }
        });
    }


    var bar = document.querySelectorAll(".aui-bar-btn");
    if (bar) {
        for (var i = 0; i < bar.length; i++) {
            var d = bar[i];
            var tab = new auiTab({
                element: bar[i],
                repeatClick: true
            }, function (ret) {
                //alert( JSON.stringify( ret ) );
                if (ret.dom.parentNode.getAttribute("type") && ret.dom.parentNode.getAttribute("type") == "count") {
                    var count = parseInt(document.getElementById("count").value);
                    if (ret.index == 2) return;
                    if (ret.index == 1) {
                        if (document.getElementById("count").value <= 1) {
                            return;
                        }
                        document.getElementById("count").value = count - 1;
                    }
                    if (ret.index == 3) {
                        document.getElementById("count").value = count + 1;
                    }
                }
            });

        }
    }


    function openWin(name) {
        var delay = 0;
        if (api.systemType != 'ios') {
            delay = 300;
        }
        api.openWin({
            name: '' + name + '',
            url: '' + name + '.html',
            bounces: false,
            delay: delay,
            slidBackEnabled: true,
            vScrollBarEnabled: false
        });
    }
</script>
</html>
